﻿using Mono.Cecil;

namespace Cil.Ast;

/// <summary>
/// Should be used to emulate pushing exception object to stack by SEH, because this is out of flow.  
/// </summary>
public sealed class CatchPushExpression : Expression
{
	public CatchPushExpression(Context context, TypeReference ref_catchType) : base(context)
	{
		// base class
		ReturnType = ref_catchType;
		WritesStack = 1;
		Nodes = new FixedList<Expression>();
	}

	/// <inheritdoc/>
	public override bool IsParsed
	{
		get { return true; }
	}

	/// <inheritdoc/>
	public override bool IsEmpty
	{
		get { return false; }
	}

	public override string ToString()
	{
		return string.Format("[CatchPushExpression]");
	}
}

public static partial class IlAst
{
	public static CatchPushExpression CatchPush(Context context, TypeReference ref_catchType)
	{
		return new CatchPushExpression(context, ref_catchType);
	}
}